package sk.xorty.si;

import org.apache.log4j.Logger;
import org.springframework.integration.annotation.Transformer;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Map;

@Component
public class ContentTransformer {

    private static final String CONTENT = "content";
    private static final String DELIMITER = ";";

    @Transformer
    public String[] transform(Map<?, ?> map) {
        System.out.println("======== TRANSFORMING MESSAGE ========");
        System.out.println("\t=> Original data: " + map);
        String content = map.get(CONTENT).toString();

        String[] contents = content.split(DELIMITER);
        System.out.println("\t=> Transformed data:" + Arrays.toString(contents));

        return contents;
    }

}
